package openase.audiosearch.job;

import java.nio.channels.SelectionKey;

import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class CancellationJob extends Job {

	private static final Log logger = LogFactory.getLog(CancellationJob.class);

	public CancellationJob(SelectionKey sk) {
		super(sk);
	}

	public void run() {
		SelectionKey key = key();

		key.cancel();

		IOUtils.closeQuietly(key.channel());

		logger.info(String.format("Cancelled: %s [%s]", key, key.channel()));
	}
}
